package com.fagp.mew.cms.controller;

import com.fagp.mew.cms.messages.PageRequest;
import com.fagp.mew.cms.messages.PageResponse;
import com.fagp.mew.cms.service.impl.SysWebService;
import com.mew.common.entity.sys.Bulletin;
import com.mew.common.entity.sys.Maintenance;
import com.mew.common.vo.BulletinVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.HandlerMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("sys")
public class SysController {


    @Autowired
    private SysWebService sysWebService;
    /**
     * 维护白名单
     */
    @ResponseBody
    @RequestMapping("whitelist")
    public PageResponse whitelist(){
        return sysWebService.whitelist();
    }

    /**
     * 添加白名单
     */
    @ResponseBody
    @RequestMapping("/addwhitelist/{uid}")
    public PageResponse addwhitelist(@PathVariable("uid")Long uid){
        return sysWebService.addwhitelist(uid);
    }

    /**
     * 删除白名单
     */
    @ResponseBody
    @RequestMapping("/delwhitelist/{gid}")
    public PageResponse delwhitelist(@PathVariable("gid") String gid){
        return sysWebService.delwhitelist(gid);
    }

    @ResponseBody
    @RequestMapping("allmaint")
    public PageResponse getMaintenances(PageRequest p){

        return sysWebService.getMaintenances(p);
    }

    /**
     * 修改公告
     */
    @ResponseBody
    @RequestMapping("addmaint")
    public PageResponse addmaint(Maintenance maintenance){
        return sysWebService.addMaintenance(maintenance);
    }

    /**
     * 围护模式
     */
    @ResponseBody
    @RequestMapping("/maintstate/{id}/{state}")
    public PageResponse maintstate(@PathVariable(value = "id")Integer id, @PathVariable(value = "state")Integer state){

        return sysWebService.maintenanceState(id,state);
    }


    /**
     * 公告
     */
    @ResponseBody
    @RequestMapping("bulletin")
    public PageResponse bulletin(PageRequest p){
        return sysWebService.bulletin( p);
    }

    /**
     * 修改公告
     */
    @ResponseBody
    @RequestMapping("upbulletin")
    public PageResponse upBulletin(Bulletin vo){
        return sysWebService.upBulletin(vo);
    }

    /**
     * 修改公告
     */
    @ResponseBody
    @RequestMapping("/bulletinstate/{id}/{state}")
    public PageResponse bulletinstate(@PathVariable(value = "id")Integer id, @PathVariable(value = "state")Integer state){

        return sysWebService.bulletinState(id,state);
    }

}
